using System;
using System.Text;

using VCDepend.Engine;

namespace VCDepend.Tests.Stubs
{
	public class StubDependencyAction : IDependencyAction
	{
		private string m_lastTo;
		private StringBuilder m_resultBuilder;

		public StubDependencyAction()
		{
			m_resultBuilder = new StringBuilder();
			m_lastTo = string.Empty;
		}

		public void OnDependencyNode(string name, string[] dependencies)
		{
			string suffix = dependencies.Length > 0 ? ":" : "";

			if (m_resultBuilder.Length > 0)
				m_resultBuilder.Append(" ");

			m_resultBuilder.AppendFormat("{0}{1}", name, suffix);
			for (int i = 0; i < dependencies.Length; ++i)
			{
				if (i > 0)
					m_resultBuilder.Append(",");

				m_resultBuilder.Append(dependencies[i]);
			}

			m_resultBuilder.Append(".");
		}

		public string Result
		{
			get
			{
				return m_resultBuilder.ToString();
			}
		}
	}
}
